<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.5"/>
<title>Theron: Theron::Actor::Actor</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">Theron
   &#160;<span id="projectnumber">6.00.02</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.5 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Macros</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="namespaceTheron.html">Theron</a></li><li class="navelem"><a class="el" href="classTheron_1_1Actor.html">Actor</a></li>  </ul>
</div>
</div><!-- top -->
<div class="contents">
<table cellspacing="0" cellpadding="0" border="0">
  <tr>
   <td valign="top">
      <div class="navtab">
        <table>
          <tr><td class="navtab"><a class="qindexHL" href="classTheron_1_1Actor_a87c458ad24c3429da325ea6f207267f4.html#a87c458ad24c3429da325ea6f207267f4">Actor</a></td></tr>
          <tr><td class="navtab"><a class="qindex" href="classTheron_1_1Actor_a3da98155747d33d767fe12b8b8c13aac.html#a3da98155747d33d767fe12b8b8c13aac">DeregisterHandler</a></td></tr>
          <tr><td class="navtab"><a class="qindex" href="classTheron_1_1Actor_a268613b27d2d718b55e2eb489118aa04.html#a268613b27d2d718b55e2eb489118aa04">GetAddress</a></td></tr>
          <tr><td class="navtab"><a class="qindex" href="classTheron_1_1Actor_afe30f86e99ff80691ec11e207711a46a.html#afe30f86e99ff80691ec11e207711a46a">GetFramework</a></td></tr>
          <tr><td class="navtab"><a class="qindex" href="classTheron_1_1Actor_a4f6af5dba4b36bbb55ee216589ccfb63.html#a4f6af5dba4b36bbb55ee216589ccfb63">GetNumQueuedMessages</a></td></tr>
          <tr><td class="navtab"><a class="qindex" href="classTheron_1_1Actor_a8b85886531b76f0e6aa9b46004ff6bb0.html#a8b85886531b76f0e6aa9b46004ff6bb0">IsHandlerRegistered</a></td></tr>
          <tr><td class="navtab"><a class="qindex" href="classTheron_1_1Actor_a8d5ef774be6470b8a1e8159f93aac07a.html#a8d5ef774be6470b8a1e8159f93aac07a">RegisterHandler</a></td></tr>
          <tr><td class="navtab"><a class="qindex" href="classTheron_1_1Actor_a47c64d58a7a683b34101002989d7de0a.html#a47c64d58a7a683b34101002989d7de0a">Send</a></td></tr>
          <tr><td class="navtab"><a class="qindex" href="classTheron_1_1Actor_a752faea0ecbb7f9525c02ed1ef19cbaf.html#a752faea0ecbb7f9525c02ed1ef19cbaf">SetDefaultHandler</a></td></tr>
          <tr><td class="navtab"><a class="qindex" href="classTheron_1_1Actor_ab8806dfed72869b22d966968340268c3.html#ab8806dfed72869b22d966968340268c3">SetDefaultHandler</a></td></tr>
          <tr><td class="navtab"><a class="qindex" href="classTheron_1_1Actor_a8ad74c59dded739fd71a66b96bc79ea8.html#a8ad74c59dded739fd71a66b96bc79ea8">TailSend</a></td></tr>
          <tr><td class="navtab"><a class="qindex" href="classTheron_1_1Actor_a95ce244d6cd6f4f3bfaea29dfb89ab6c.html#a95ce244d6cd6f4f3bfaea29dfb89ab6c">~Actor</a></td></tr>
        </table>
      </div>
   </td>
   <td valign="top" class="mempage">
<a class="anchor" id="a87c458ad24c3429da325ea6f207267f4"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">Theron::Actor::Actor </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classTheron_1_1Framework.html">Framework</a> &amp;&#160;</td>
          <td class="paramname"><em>framework</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *const&#160;</td>
          <td class="paramname"><em>name</em> = <code>0</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">explicit</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Explicit constructor. </p>
<p>Constructs an actor within the given <a class="el" href="classTheron_1_1Framework.html">Framework</a>, with the given unique name. If the name parameter is null then the actor is given an automatically generated name.</p>
<p>The <a class="el" href="classTheron_1_1Actor.html" title="The actor baseclass. ">Actor</a> baseclass constructor expects an instance of the <a class="el" href="classTheron_1_1Framework.html" title="Manager class that hosts, manages, and executes actors. ">Framework</a> class, which becomes the owning <a class="el" href="classTheron_1_1Framework.html" title="Manager class that hosts, manages, and executes actors. ">Framework</a> for the actor, hosting it and executing its message handlers.</p>
<p>When defining their own derived actor classes, users must arrange to pass a <a class="el" href="classTheron_1_1Framework.html" title="Manager class that hosts, manages, and executes actors. ">Framework</a> object to the baseclass constructor. The typical way to arrange this is to just expose the same parameter on the constructor of the derived actor, and pass it through to the baseclass constructor in the initializer list:</p>
<p>The optional name parameter allows constructed actor objects to be given unique, user-defined names. These names can then be used to send messages to the actors in situations where the sending code has no direct reference to the destination actor, so can't query it for its address. This is especially important when sending messages to remote actors, where the actor is also required to be constructed in a <a class="el" href="classTheron_1_1Framework.html" title="Manager class that hosts, manages, and executes actors. ">Framework</a> tied to an <a class="el" href="classTheron_1_1EndPoint.html">EndPoint</a>.</p>
<p>If no name parameter is provided, or the name parameter is null, then the constructed actor is given an automatically generated name. The generated name can still be used to send messages, but since it is automatically generated it can't be known to the user except by calling <a class="el" href="classTheron_1_1Actor_a268613b27d2d718b55e2eb489118aa04.html#a268613b27d2d718b55e2eb489118aa04">GetAddress</a>. Note that the generated name is only guaranteed to be unique across all processes if each <a class="el" href="classTheron_1_1EndPoint.html">EndPoint</a> in the system is given a unique, user-defined name on construction.</p>
<dl class="section note"><dt>Note</dt><dd>Sending a message to an actor using only its name requires an <a class="el" href="classTheron_1_1EndPoint.html">EndPoint</a>. It involves a hashed lookup, so is slower than using an address retrieved directly from the target actor using <a class="el" href="classTheron_1_1Actor_a268613b27d2d718b55e2eb489118aa04.html#a268613b27d2d718b55e2eb489118aa04">GetAddress</a>.</dd></dl>
<div class="fragment"><div class="line"><span class="keyword">class </span>MyActor : <span class="keyword">public</span> <a class="code" href="classTheron_1_1Actor.html">Theron::Actor</a></div>
<div class="line">{</div>
<div class="line"><span class="keyword">public</span>:</div>
<div class="line"></div>
<div class="line">    MyActor(<a class="code" href="classTheron_1_1Framework.html">Theron::Framework</a> &amp;framework, <span class="keyword">const</span> <span class="keywordtype">char</span> *<span class="keyword">const</span> name) :</div>
<div class="line">      Theron::<a class="code" href="classTheron_1_1Actor_a87c458ad24c3429da325ea6f207267f4.html#a87c458ad24c3429da325ea6f207267f4">Actor</a>(framework, name)</div>
<div class="line">    {</div>
<div class="line">    }</div>
<div class="line">};</div>
<div class="line"></div>
<div class="line"><a class="code" href="structTheron_1_1EndPoint_1_1Parameters.html">Theron::EndPoint::Parameters</a> params(<span class="stringliteral">&quot;local&quot;</span>, <span class="stringliteral">&quot;tcp://192.168.10.104:5555&quot;</span>);</div>
<div class="line"><a class="code" href="classTheron_1_1EndPoint.html">Theron::EndPoint</a> endPoint(params);</div>
<div class="line"><a class="code" href="classTheron_1_1Framework.html">Theron::Framework</a> framework(endPoint);</div>
<div class="line"><a class="code" href="classTheron_1_1Receiver.html">Theron::Receiver</a> receiver(endPoint, <span class="stringliteral">&quot;receiver&quot;</span>);</div>
<div class="line"></div>
<div class="line">MyActor actorOne(framework, <span class="stringliteral">&quot;actor_one&quot;</span>);</div>
<div class="line">MyActor actorTwo(framework, <span class="stringliteral">&quot;actor_two&quot;</span>);</div>
<div class="line"></div>
<div class="line">framework.Send(</div>
<div class="line">    std::string(<span class="stringliteral">&quot;hello&quot;</span>),</div>
<div class="line">    <a class="code" href="classTheron_1_1Address.html">Theron::Address</a>(<span class="stringliteral">&quot;receiver&quot;</span>),</div>
<div class="line">    <a class="code" href="classTheron_1_1Address.html">Theron::Address</a>(<span class="stringliteral">&quot;actor_one&quot;</span>));</div>
</div><!-- fragment --><p>A powerful feature of actors is that they can create other actors, allowing the building of complex subsystems of actors using object-like abstraction. See the documentation of the <a class="el" href="classTheron_1_1Actor_afe30f86e99ff80691ec11e207711a46a.html#afe30f86e99ff80691ec11e207711a46a">GetFramework</a> method for more information.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">framework</td><td>Reference to a framework within which the actor will be hosted. </td></tr>
    <tr><td class="paramname">name</td><td>An optional string defining the unique name of the actor object.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>The string name parameter is copied so can be destroyed after the call. </dd></dl>

</div>
</div>
    </td>
  </tr>
</table>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.5
</small></address>
</body>
</html>
